<template>
	<!-- 顶部返回部分 -->
	<div class="top">
		<nav-bar
			style="padding-top: 0.9375rem"
			title="新闻资讯"
			left-text=""
			fixed="true"
			left-arrow
			@click-left="onClickLeft"
		>
		</nav-bar>
		<p class="top-two">
			<notice-bar
				text="无论我们能活多久，我们能够享受的只有无法分割的此刻，此外别无其他。"
			/>
		</p>
	</div>
	<div class="bottom" v-for="item in data" @click="clickHandle(item)">
		<div class="left">
			<p class="p-title">{{ item.title }}</p>
			<p class="p-text" v-text="dalHtml(item.text)"></p>
			<p class="p-time">{{ item.createTime }}</p>
		</div>
		<div class="p-img">
			<img :src="dalImg(item.cover)" alt="" />
		</div>
	</div>
</template>
<script setup>
import { ref } from "vue";
import { useRouter } from "vue-router";
import { NavBar, NoticeBar } from "vant";
import { localArticleAPI } from "../API/jiang";
import { dalImg } from "../Utils/tools";
import axios from "../utils/request";
import { dalHtml } from "../utils/tools";
const router = useRouter();

const clickHandle = (item) => {
	router.push({
		name: "Home-essay",
		query: { id: item.id },
	});
};

//调用接口
const data = ref([]);
// 根据当前id获取数据
localArticleAPI().then((res) => {
	data.value = res.data.records;
	console.log(data.value);
});
const onClickLeft = () => {
	router.go(-1);
};
</script>
<style scoped>
.bottom {
	display: flex;
	box-shadow: -0.0625rem 0rem 0rem gray;
	background-color: #fff;
}
.left {
	width: 70%;
	display: flex;
	flex-direction: column;
}
.p-text {
	width: 100%;
	overflow: hidden;
	-webkit-line-clamp: 2;
	display: -webkit-box;
	-webkit-box-orient: vertical;
	text-overflow: ellipsis;
	font-size: 0.8125rem;
	color: gray;
	margin: 0.9375rem 0.625rem 0.9375rem 0.625rem;
}
.p-time {
	margin: 0rem 0.625rem 0 0.625rem;
	font-size: 0.75rem;
	color: gray;
}
.p-title {
	width: 100%;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	margin: 0.9375rem 0.625rem 0 0.625rem;
}
img {
	width: 80%;
	height: 80%;
	border-radius: 0.625rem;
}
.p-img {
	width: 5rem;
	flex: 1;
	height: 8.125rem;
	display: flex;
	justify-content: center;
	align-items: center;
}
.main-main {
	height: 100vh;
	width: 90%;
	margin: auto;
	line-height: 1.875rem;
}
.top {
	width: 100%;
	height: 4.6875rem;
}
.main {
	/* height: 100vh; */
}
.top-two {
	width: 35%;
	position: fixed;
	top: 0.9375rem;
	right: 33%;
	z-index: 11;
}
.top .van-notice-bar {
	background-color: #fff;
}
</style>
